* Improved handling of --time-limit when combined with -J
* Fix updating git index file after getting an unlocked file
when annex.stalldetection is set.
+ * test: Added --test-with-git-config option.
-- Joey Hess <id@joeyh.name> Mon, 29 Aug 2022 15:03:04 -0400
{- git-annex test suite
-
- - Copyright 2010-2021 Joey Hess <id@joeyh.name>
+ - Copyright 2010-2022 oey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
import Types.RepoVersion
import Types.Concurrency
import Test.Framework
-import Options.Applicative.Types
import Test.Tasty
import Test.Tasty.HUnit
import Test.Tasty.QuickCheck
-import Options.Applicative (switch, long, short, help, internal, maybeReader, option)
+import Options.Applicative.Types
+import Options.Applicative (switch, long, short, help, internal, maybeReader, option, metavar)
import qualified Data.Map as M
import qualified Data.ByteString.Lazy.UTF8 as BU8
optParser :: Parser TestOptions
optParser = TestOptions
- <$> snd (tastyParser (tests 1 False True (TestOptions mempty False False Nothing mempty)))
+ <$> snd (tastyParser (tests 1 False True (TestOptions mempty False False Nothing mempty mempty)))
<*> switch
( long "keep-failures"
<> help "preserve repositories on test failure"
<> short 'J'
<> help "number of concurrent jobs"
))
+ <*> many (option (maybeReader parseconfigvalue)
+ ( long "test-git-config"
+ <> help "run tests with a git config set"
+ <> metavar "NAME=VALUE"
+ ))
<*> cmdParams "non-options are for internal use only"
+ where
+ parseconfigvalue s = case break (== '=') s of
+ (_, []) -> Nothing
+ (k, v) -> Just
+ ( Git.Types.ConfigKey (encodeBS k)
+ , Git.Types.ConfigValue (encodeBS (drop 1 v))
+ )
runner :: TestOptions -> IO ()
runner opts = parallelTestRunner opts tests
case r of
Right () -> return ()
Left e -> do
- whenM (keepFailures <$> getTestMode) $
+ whenM (keepFailuresOption . testOptions <$> getTestMode) $
putStrLn $ "** Preserving repo for failure analysis in " ++ clone
throwM e
-- tell git-annex to not annex the ingitfile
git "config" ["annex.largefiles", "exclude=" ++ ingitfile]
"git config annex.largefiles"
+ -- set any additional git configs the user wants to test with
+ gc <- testGitConfig . testOptions <$> getTestMode
+ forM_ gc $ \case
+ (Git.Types.ConfigKey k, Git.Types.ConfigValue v) ->
+ git "config" [decodeBS k, decodeBS v]
+ "git config from test options"
+ (Git.Types.ConfigKey _, Git.Types.NoConfigValue) -> noop
ensuredir :: FilePath -> IO ()
ensuredir d = do
{ unlockedFiles :: Bool
, adjustedUnlockedBranch :: Bool
, annexVersion :: Types.RepoVersion.RepoVersion
- , keepFailures :: Bool
- } deriving (Show)
+ , testOptions :: TestOptions
+ }
testMode :: TestOptions -> Types.RepoVersion.RepoVersion -> TestMode
testMode opts v = TestMode
{ unlockedFiles = False
, adjustedUnlockedBranch = False
, annexVersion = v
- , keepFailures = keepFailuresOption opts
+ , testOptions = opts
}
hasUnlockedFiles :: TestMode -> Bool
import Types.Concurrency
import Types.Command
+import Git.Types
data TestOptions = TestOptions
{ tastyOptionSet :: OptionSet
, keepFailuresOption :: Bool
, fakeSsh :: Bool
, concurrentJobs :: Maybe Concurrency
+ , testGitConfig :: [(ConfigKey, ConfigValue)]
, internalData :: CmdParams
}
When there are test failures, leave the `.t` directory populated with
repositories that demonstate the failures, for later analysis.
+* `--test-git-config name=value`
+
+ The test suite prevents git from reading any git configuration files.
+ Usually it is a good idea to run the test suite with a standard
+ git configuration. However, this option can be useful to see what
+ effect a git configuration setting has on the test suite.
+
+ Some configuration settings will break the test suite, in ways that are
+ due to a bug in git-annex. But it is possible that changing a
+ configuration can find a legitimate bug in git-annex.
+
+ One valid use of this is to change a git configuration to a value that
+ is planned to be the new default in a future version of git.
+
# SEE ALSO
[[git-annex]](1)
`git-annex test` prevents ~/.gitconfig or /etc/gitconfig from being read.
+The `-c` option also doesn't propagate into the test suite.
It would sometimes be useful to test git-annex with a given git config set.
Although some might break the test suite, others might expose actual bugs
in git-annex. --[[Joey]]
+
+> Added "--test-git-config" option, [[done]] --[[Joey]]